package controller.login;

import java.awt.Font;
import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import util.base.VerifyCodeUtil;
@Controller
@RequestMapping(value="/common")
public class VerificationCodeController {
	@RequestMapping(value="/getVerificationCode")
	@ResponseBody
	public void getVerificationCode(HttpServletRequest req,HttpServletResponse res){
		res.setHeader("Pragma", "No-cache"); 
		res.setHeader("Cache-Control", "no-cache"); 
		res.setDateHeader("Expires", 0); 
		res.setContentType("image/jpeg"); 
		try {
			String randomCode=new VerifyCodeUtil().getImages(res.getOutputStream(),100, 50, null, 4, 4,new Font("楷体",Font.BOLD,18));
			req.getSession().setAttribute("verificationCode", randomCode);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
